package 面试常见刷题;

import java.util.Arrays;

public class 希尔排序 {
    public static void main(String[] args) {
        int[] ints = {1, 213, 12, 31, 41, 12};
        xierSort(ints);
        System.out.println(Arrays.toString(ints));
    }

    public static void xierSort(int[] data) {
        insertSort(data,5);
        insertSort(data,3);
        insertSort(data,1);
    }

    public static void insertSort(int[] data, int step) {
        for (int i = 1; i < data.length; i += step) {
            for (int j = i - 1; j >= 0; j -= step) {
                if (data[j] > data[j + 1]) {
                    工具类.swap(data, j, j + 1);
                } else {
                    break;
                }
            }
        }
    }
}
